﻿using System.Security.Claims;

namespace BlazorApp派单.auth
{
    public class UserStateService
    {
        public ClaimsPrincipal User { get; private set; } = new ClaimsPrincipal(new ClaimsIdentity());

        public void SetUser(string username)
        {
            var identity = new ClaimsIdentity(new[]
            {
            new Claim(ClaimTypes.Name, username),
        }, "custom-auth-type");

            User = new ClaimsPrincipal(identity);
        }

        public void Logout()
        {
            User = new ClaimsPrincipal(new ClaimsIdentity());
        }
    }
}
